<?php
/**
 * 首页->每日考勤
 * 考勤状态显示
 * @author dinglin
 *
 */
apf_require_class('Oa_Test_AbstractTest');
class Oa_Test_Util_MoreTest extends Oa_Test_AbstractTest {

    private $bll;
    public function setUp(){
        apf_require_class('Bll_Attendance_DailyLeave');
        apf_require_class('Oa_Data_UserInfo');
        apf_require_class('Oa_Data_UserDayStatus');
        $this->bll = new Bll_Attendance_DailyLeave();
    }
    public function tearDown(){
        unset($this->bll);
    }
    /**
     * 主逻辑测试
     * 主要测试考勤状态
     * 在传入的用户Id 考勤开始结束时间正常(Ymd)
     * 在打卡处理正常，异常原因提交正常，请假/出差/公出正常，审核批准/驳回/撤销正常
     * 以上一切正常的情况下，才能保证此测试的逻辑处理正常。
     */
    public function test_main_index(){
        //初始化测试数据
        // set_user_info     用户信息
        $users = Oa_Data_UserInfo::get_instance()->get_all_users();
        $uid = 6439;
        $users = $users[$uid];
        $this->bll->set_user_info($users);
        $start = 20120903;
        $end = 20120903;
        // set_attendance    用户打卡状态
        //$user_day_status = Oa_Data_UserDayStatus::get_instance()->get_user_day_status(5652, 20121001,0, 31,false);
        $data_user_day_status = array(
                Array(
                        'user_id' => $uid,
                        'dateline' => $start,
                        'days' => 1.0,
                        'am_status' => 3,
                        'am_type' => 0,
                        'am_leave_status' => 0,
                        'pm_status' => 4,
                        'pm_type' => 0,
                        'pm_leave_status' => 0,
                        'is_later' => 0,
                        'leave_early' => 0
                )
        );
        $this->bll->set_attendance($uid, $start, $end,$data_user_day_status);
        // set_record        每日打卡记录
        $data_days_record = array(
                Array(
                        'id' => 30578,
                        'access_date' => $start,
                        'start_work' => '0942',
                        'end_work' => '1710',
                        'user_id' => $uid,
                        'updated' => 1346663412,
                        'created' => 1346633404
                )
        );
        $this->bll->set_record($uid, $start, $end,$data_days_record);
        //set_check_day_work_status  check
        $data_check_status = array(3,4);
        $this->bll->set_check_day_work_status($data_check_status);
        // set_prev_data     上月未清数据记录
        $this->bll->set_prev_data($uid, $start, $end, array());
        // set_curr_data     迟到公出出差早退数据记录
        $this->bll->set_curr_data($uid, $start, $end, array());
        // set_next_data     用户请假记录每半天区分
        $this->bll->set_next_data($uid, $start, $end, array());
        // set_leaves_on_ids 用户请假记录
        $this->bll->set_leaves_on_ids(array());

        //do test
        //实际数据
        $result = $this->bll->get_attendance_list($uid,$start,$end);
        //期望数据
        $expect = array(
                'kq_detail'=>'09:42-17:10',
                'view_work'=>'<span class="chi">09:42</span>-<span class="chi">17:10</span>',
                'view_record'=>array(array('type'=>'<span class="chi">全天缺勤</span>','date'=>'2012-09-03')),
                'view_detail'=>array(array())
         );
        $temp = array();
        foreach($expect as $index=>$value){
            if(isset($result[$start][$index])){
                $temp[$index] = $result[$start][$index];
            }
        }
        //assert
        $this->assertEquals($expect,$temp,"每日状态");
    }
}